package com.android.websms;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class DBPenTest extends SQLiteOpenHelper
{

	private static final String	DATABASE_NAME						= "webapp.db";
	private static final int		DATABASE_VERSION				= 2;

	private SQLiteDatabase			dbRead;
	private SQLiteDatabase			dbWrite;

	public DBPenTest(Context context)
	{
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		dbRead = this.getReadableDatabase();
		dbWrite = this.getWritableDatabase();
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		db.execSQL("CREATE TABLE text (text TEXT);");

		this.dbWrite = db;
		this.dbRead = db;
		// TODO Auto-generated method stub

	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2)
	{
		// TODO Auto-generated method stub

	}
	
	
	public void addMessage(String text)
	{
		ContentValues cv = new ContentValues();
		cv.put("text", text);
		dbWrite.insert("text", null, cv);
	}
	
	public Cursor getMessages()
	{
		return dbRead.query("text", new String[] {"text"}, "1", null, null, null, null);
	}
	

}
